home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
btrees2.arc
/
BTACSLIB.C
next >
Wrap
Text File
|
1984-12-14
|
3KB
|
144 lines
/* btsys access library */
#include <stdio.h>
#define INTCHAR 388
#define INTINT 392
#define INTKEY 396
static unsigned seg, offset;
static int *word,i;
static int parm [] = { 0, 0 , 0, 0, 0 };
static char filnam[] = " ";
static char filkey[] = " ";
static struct { int cs,ss,ds,es;} segreg,*segregp;
static int fromoff,fromseg,*tooff,toseg;
extern struct {
unsigned fcode;
unsigned keylen;
unsigned filhand;
unsigned datapt;
char filkey[17];
char filnam[15];
} btstruct, *structp;
/* and it begins !!!!!! */
static int btinit ()
{
segread(&segreg);
/* set up int decimal INTINT */
seg = 0;
offset = INTINT;
word = parm;
pokew (offset, seg, word);
offset = INTINT + sizeof (int);
word = segreg.ds;
pokew (offset, seg, word);
/* set up int decimal INTCHAR */
seg = 0;
offset = INTCHAR;
word = filnam;
pokew (offset, seg, word);
offset = INTCHAR + sizeof (int);
word = segreg.ds;
pokew (offset, seg, word);
/* set up int decimal INTKEY */
seg = 0;
offset = INTKEY;
word = filkey;
pokew (offset, seg, word);
offset = INTKEY + sizeof (int);
word = segreg.ds;
pokew (offset, seg, word);
} /* end btinit */
/* do btsys interrupt */
static int btintr ()
{
int times;
struct regval {
int ax, bx, cx, dx, si, di, ds, es;}
*xxv, yyv;
struct {int cs, ss, xds, xes;} *rrv,ssv;
rrv = &ssv;
segread (rrv);
yyv.ds = rrv->xds;
yyv.es = rrv->xes;
xxv = &yyv;
sysint (0x60, xxv, xxv); /* execute the interrupt */
} /* end btintr */
/* btfunc */
/* performs interface functions between user programs
and the btree system
*/
int btfunc (structp)
struct btstruct *structp;
{
switch (structp->fcode) {
case 0 : btinit (); /* initialize address for interrupts */
break;
case 1: /* file create */
case 2: /* file open */
parm[0] = structp->fcode;
parm[1] = structp->keylen;
parm[2] = NULL;
parm[3] = NULL;
parm[4] = NULL;
strcpy (filnam, structp->filnam);
strcpy (filkey, "");
break;
case 3 : /* file close */
parm[0] = structp->fcode;
parm[1] = NULL;
parm[2] = structp->filhand;
parm[3] = NULL;
parm[4] = NULL;
strcpy (filnam, "");
strcpy (filkey, "");
break;
case 4 : /* key insert */
parm[0] = structp->fcode;
parm[1] = NULL;
parm[2] = structp->filhand;
parm[3] = NULL;
parm[4] = structp->datapt;
strcpy (filnam, "");
strcpy (filkey, structp->filkey);
break;
case 5 : /* random read */
parm[0] = structp->fcode;
parm[1] = NULL;
parm[2] = structp->filhand;
parm[3] = NULL;
parm[4] = NULL;
strcpy (filnam,"");
strcpy (filkey, structp->filkey);
break;
default : /* bad function code */
return (10);
break;
} /* end switch */
/* now perform the btsys interrupt */
btintr ();
/* set return values for user program */
structp->fcode = parm[0];
structp->filhand = parm[2];
structp->datapt = parm[4];
return (parm[3]);
} /* end of btfunc */
/* THE END */